package wwy.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name = "熔断服务")
@RequestMapping("/fallback")
public class FallBackController {
    private final DiscoveryClient discoveryClient;
    public  FallBackController(DiscoveryClient discoveryClient) {
        this.discoveryClient = discoveryClient;
    }
    @GetMapping("/fallback")
    @Operation(summary = "熔断服务")
    public String fallBack(){
        return "该服务暂时异常，产生了熔断，请稍后再试！";
    }
    @GetMapping("/services")
    @Operation(summary = "获取服务列表")
    public List<String> getServices() {
        return discoveryClient.getServices();
    }
}
